﻿using System;

using BLL;
using Model;
using Utility;

namespace EvaluationSystem
{
    public partial class AddPosition : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ((SiteSystemMaster)Master).InitMenu();
            ((SiteSystemMaster)Master).li2.Attributes.Add("class", "hover ccc");
            ((SiteSystemMaster)Master).b_hmenu1.Style.Add("display", "none");
            ((SiteSystemMaster)Master).b_hmenu2.Style.Clear();
            ((SiteSystemMaster)Master).b_hmenu3.Style.Add("display", "none");
            ((SiteSystemMaster)Master).s_menu2_2.Style.Add("COLOR", "#147ab8");
            ((SiteSystemMaster)Master).s_menu2_2.Style.Add("TEXT-DECORATION", "none"); 

            /*判断是否是管理员身份*/
            if (Session["username"] == null)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "<script>alert('请先登录系统!');top.location.href='../System/Login.aspx';</script>");
                return;
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            PositionBLL positionBLL = new PositionBLL();

            Position  temp = new  Position();

            temp.Position_name = txtbPositionname.Text.Trim();
            temp.Position_description = txtbPositionDes.Text.Trim();

            if (positionBLL.Add(temp) !=-1)
            {
                MessageBox.ShowAndRedirect(this, "添加成功", "PositionList.aspx");
            }
            else
            {
                MessageBox.ShowAndRedirect(this, "添加失败", "PositionList.aspx");
            }
        }

        protected void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/System/PositionList.aspx");
        }
    }
}